#ifndef __GAME_H__
#define __GAME_H__

#include <set>
#include <wiisprite.h>

#include "actor.h"
#include "missileactor.h"
#include "shockwaveactor.h"
#include "siloactor.h"
#include "textactor.h"
#include "imageloader.h"
#include "pcmloader.h"
#include "gameaction.h"

using std::set;
using namespace wsp;

class GameTrigger;

class Game
{
public:
  Game();
  ~Game();
  void initialize();
  void activate();
  void update();
  void draw();
  
  void doMoveSilos();
  void doFirePlayerMissile();
  void updateAllActors();
  void replenishEnemyMissiles();
  void handleSplitMissiles();
  void handleCollisions();
  void handleExplosions();
  void cleanupActors();

  void setFade(f32 fade, bool force = false);
  void updateFade();
  MissileActor *doFireMissileAt(f32 xs, f32 ys, f32 xf, f32 yf, MissileActor::Type owner, int splitafter = -1);

public:
  ImageLoader imgload;
  PcmLoader pcmload;

  set<MissileActor*> playermissiles;
  set<MissileActor*> enemymissiles;
  set<MissileActor*> missiles;
  set<ShockwaveActor*> shockwaves;
  set<SiloActor*> silos;
  set<Actor*> actors;
  
  SiloActor *siloleft;
  SiloActor *silocenter;
  SiloActor *siloright;

  TextActor *modaltext;

  Sprite grass;
  Sprite crosshairs;
  Sprite silodomeleft;
  Sprite silodomecenter;
  Sprite silodomeright;

  f32 px,py;
  
  bool enablePlayerControl;
  bool enableSilos;
  bool enableMissiles;
  bool enableShockwaves;
  bool enableHealthBar;
  bool enableAmmoBar;
  bool enableMissileTargets;
  bool enableBackground;
  bool enableCrosshairs;
  bool enableText;
  bool enableConsole;
  
  bool pause;
  
  f32 fade;
  f32 targetfade;
  
  u32 t;
  u32 timerend;
  
  GameActionList rootlist;
  GameActionList *al;
  vector<GameTrigger*> triggers;

  friend class GameAction;
};

#endif
